home *** CD-ROM | disk | FTP | other *** search
- on legalLogin
- global gStuList, gStuLogin, gStuListPath
- set p to getPos(gStuList, gStuLogin)
- if p = 0 then
- return EMPTY
- else
- return getAt(gStuListPath, p)
- end if
- end
-
- on startGuest
- global gStuLogin, gTest, gTimer, gBlindfold, gStuInfo
- set gStuLogin to "GUEST"
- set gTest to 0
- set gTimer to 0
- set gBlindfold to 0
- set gStuInfo to [#name: "GUEST"]
- set the keyDownScript to "handleKey"
- readprefs()
- updateStage()
- goChangeMeta("selectStart")
- end
-
- on checkUser
- global gStuLogin, gSMSStuPath
- set gStuLogin to field "Login Name"
- set gStuLogin to upperCase(gStuLogin)
- set c to the number of chars in gStuLogin
- if char c of gStuLogin = " " then
- delete char c of gStuLogin
- end if
- if char 1 of gStuLogin = " " then
- delete char 1 of gStuLogin
- end if
- if gStuLogin = "GUEST" then
- startGuest()
- else
- set path to legalLogin()
- if path <> EMPTY then
- set the keyDownScript to "handleKey"
- updateStage()
- set gSMSStuPath to path & gStuLogin
- loginLoad(gSMSStuPath)
- else
- alert(field "No Record")
- unhighlight(13)
- end if
- end if
- end
-
- on loginLoad thePath
- global gTest, gTimer
- set err to loginStudent(thePath)
- if err <> #NOERR then
- if err = #ERRSTUINFO then
- alert("Error in loading student information")
- loadServerLists()
- else
- if err = #ERRBADPASS then
- alert("Incorrect Password. Please re-enter.")
- else
- if err = #ERRORDER then
- alert("Error in loading chapter order")
- else
- if err = #ERRMETHOD then
- alert("Error in loading tutorial. See your instructor to change your tutorial setting.")
- end if
- end if
- end if
- end if
- goChangeMeta("login")
- else
- clearScore()
- set gTest to 0
- set gTimer to 0
- set ret to doMode(#sms, "skip")
- if ret = #done then
- alert("You have completed the required assignment. See your instructor for more or login as GUEST.")
- goChangeMeta("login")
- else
- if ret = #error then
- goChangeMeta("login")
- end if
- end if
- end if
- end
-
- on loginStudent thePath
- global gStuInfo, gPassword
- if not loadStuInfo(thePath) then
- return #ERRSTUINFO
- end if
- if smsPWcheck(gPassword, getaProp(gStuInfo, #PASSWORD)) = 0 then
- return #ERRBADPASS
- end if
- if not loadOrder() then
- return #ERRORDER
- end if
- if not loadMethod(thePath) then
- return #ERRMETHOD
- end if
- return #NOERR
- end
-
- on handleKeyLoginID
- if (the key = RETURN) or (the key = ENTER) then
- highlight(13)
- updateStage()
- dontPassEvent()
- checkUser()
- else
- if the key = TAB then
- dontPassEvent()
- set the keyDownScript to "handleKeyLoginPass"
- go("Password field")
- end if
- end if
- end
-
- on handleKeyLoginPass
- global gPassword
- if (the key = RETURN) or (the key = ENTER) then
- highlight(13)
- updateStage()
- dontPassEvent()
- checkUser()
- else
- if the key = TAB then
- set the keyDownScript to "handleKeyLoginID"
- go("ID field")
- else
- if the selStart <> the selEnd then
- delete char the selStart + 1 to the selEnd of gPassword
- delete char the selStart + 1 to the selEnd of field "password"
- moveCarat(the selStart)
- end if
- set k to charToNum(the key)
- if k = 8 then
- if the selStart <> 0 then
- set curs to selStart
- delete char the selStart of gPassword
- delete char the selStart of field "password"
- moveCarat(curs - 1)
- end if
- else
- if k = 127 then
- if the selStart <> the number of chars in gPassword then
- delete char the selStart + 1 of gPassword
- delete char the selStart + 1 of field "password"
- end if
- else
- if k = 28 then
- if the selStart <> 0 then
- moveCarat(the selStart - 1)
- end if
- else
- if k = 29 then
- if the selStart <> the number of chars in gPassword then
- moveCarat(the selStart + 1)
- end if
- else
- if k = 30 then
- else
- if k = 31 then
- else
- if k = 1 then
- moveCarat(0)
- else
- if k = 4 then
- moveCarat(the number of chars in gPassword)
- else
- if k = 11 then
- else
- if k = 12 then
- else
- if the selStart = 0 then
- set gPassword to the key & gPassword
- else
- if the selStart <> the number of chars in gPassword then
- set gPassword to char 1 to the selStart of gPassword & the key & char the selStart + 1 to the number of chars in gPassword of gPassword
- else
- put the key after gPassword
- end if
- end if
- put "*" after field "password"
- moveCarat(the selStart + 1)
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- dontPassEvent()
- end
-
- on moveCarat x
- set the selStart to x
- set the selEnd to x
- set the selStart to x
- set the selEnd to x
- end
-